//package com.wx_shop.api.controller.rest;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
//import org.apache.commons.lang.StringUtils;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//import com.wx_shop.api.comm.Constants;
//import com.wx_shop.api.service.UserService;
//import com.wx_shop.api.util.wx.util.WeixinUtil;
//import com.wx_shop.api.util.wx.vo.WeixinMsgReq;
//
///**
// * 微信开发者服务请求接口
// * 用户关注/取消、点击公众号、通知此接口
// * @author leiwuluan
// */
//@RequestMapping("/")
//@Controller
//public class WeiXinRest {
//	
//	private static Logger logger = LoggerFactory.getLogger(WeiXinRest.class);
//	
//	@Autowired
//	private UserService userService;
//	
//	@Autowired
//	private WeiXinService weiXinService;
//	
//	@RequestMapping(value = "/weixin", method = RequestMethod.GET)
//	@ResponseBody
//	public String weixinGet(String signature, String echostr, String timestamp, String nonce, 
//			HttpServletRequest request, HttpServletResponse response) {
//		
//		logger.info("signature={}, echostr={}, timestamp={}, nonce={}", signature, echostr, timestamp, nonce);
//		
////		userService.test();
//		
//		if(StringUtils.isNotEmpty(echostr)) {
//			boolean checkSignOk = WeixinUtil.checkSignature(Constants.WX_TOKEN, timestamp, nonce, signature);
//			logger.info("checkSignOk={}", checkSignOk);
//			if(checkSignOk) {
//				return echostr;
//			}
//		}
//		
//		return null;
//	}
//	
//	@RequestMapping(value = "/weixin", method = RequestMethod.POST, produces = "application/xml;charset=UTF-8")
//	@ResponseBody
//	public String weixinPost(@RequestBody WeixinMsgReq weixinDomain, String signature, String echostr, String timestamp, String nonce, 
//			HttpServletRequest request, HttpServletResponse response) {
//		
//		logger.info("weixinDomain={}", weixinDomain);
//		
//		if(StringUtils.isNotEmpty(timestamp) && StringUtils.isNotEmpty(nonce) && StringUtils.isNotEmpty(signature)) {
//			boolean checkSignOk = WeixinUtil.checkSignature(Constants.WX_TOKEN, timestamp, nonce, signature);
//			logger.info("checkSignOk={}", checkSignOk);
//			if(checkSignOk) {
//				weiXinService.msgAccess(weixinDomain);
//			}
//		}
//		
//		return null;
//	}
//	
////	test
////	POST signature=e16d4d88c654436cedfcaf6a502bebbdc66e9a4a&timestamp=1470011235&nonce=1314316591&openid=owZ3jv5Wrc6S2NShemtkO5jvvVQU
////	GET signature=da8f26464609ae359b04bd4b98e2a507eac14c81&echostr=7939560159824539627&timestamp=1462635808&nonce=96787020
//
//	
//}
